package com.joker.common.enums;

public enum MemberLevelEnum {

    MEMBER_LEVEL_0("0", "天会员"),
    MEMBER_LEVEL_1("1", "月会员"),
    MEMBER_LEVEL_2("2", "年度会员"),
    MEMBER_LEVEL_3("3", "永久会员");

    private final String code;
    private final String description;

    MemberLevelEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 静态方法，根据code返回对应的枚举实例
    public static MemberLevelEnum fromCode(String code) {
        for (MemberLevelEnum status : MemberLevelEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("No enum constant " + MemberLevelEnum.class.getName() + "." + code);
    }

    @Override
    public String toString() {
        return description;
    }

}
